#!/bin/bash
if ! command -v cpulimit &> /dev/null; then
    echo -e "\e[32mcpulimit is not installed. Installing now...\e[0m"
    sudo yum install -y cpulimit
else
    echo -e "\e[32mcpulimit is already installed.\e[0m"
fi
for PID in $(ps -axo pid,comm | grep cpu_task.py | awk '{print $1}')
# 默认限制每个CPU 30%使用率，请根据具体情况填写，如果为100则代表不限制
    do cpulimit -p $PID -l 30 &
    done
